package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"path"
	"path/filepath"
	"runtime"

	"gopkg.in/yaml.v3"
)

type test struct {
	Bucket   string `yaml:"bucket"`
	Region   string `yaml:"region"`
	Filetype int    `yaml:"filetype"`
}

func main() {
	var abPath string
	_, filename, _, ok := runtime.Caller(1)
	if ok {
		abPath = path.Dir(filename)
	}
	fmt.Println(abPath)
	
	ex, err := os.Executable()
	if err != nil {
		panic(err)
	}
	exPath := filepath.Dir(ex)
	fmt.Println("exPath:", exPath)
	str, _ := os.Getwd()
	fmt.Println(str)
	stat, err := os.Stat("test.yaml")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("stat:", stat)
	data, err := ioutil.ReadFile("./test.yaml")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(string(data))
	t := test{}
	err = yaml.Unmarshal(data, &t)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("%#v\n", t)
	fmt.Println("Bucket:", t.Bucket)
	fmt.Println("Region:", t.Region)
	fmt.Println("Filetype:", t.Filetype)
}
